<template>
	<view>
		<u-navbar title-color="#333" title-bold title-size="36" title="发表评价" :border-bottom="false"></u-navbar>
		<view class="u-m-t-32 u-p-l-32 u-p-r-32">
			<view class="input-div u-m-t-22 flex">
				<view class="input-lable">总体评价</view>
				<u-rate :count="5" inactive-icon="star-fill" active-color="#FEB445" inactive-color="#BBBBBB" gutter="20" v-model="value"></u-rate>
			</view>
			<view class="input-div u-m-t-20 u-padding-32">
				<u-input v-model="content" type="textarea" height="200" maxlength="100" auto-height placeholder="写出您的评价，可以帮助更多小伙伴哦~" />
			</view>
			<view class="u-m-t-24 flex u-m-t-26"  @click="chboxSel=!chboxSel">
				<view class="chbox flex_cen flex" v-if="chboxSel" >
					<u-icon name="checkbox-mark" color="#fff" size="20"></u-icon>
				</view>
				<view class="chbox-no" v-if="!chboxSel"></view>
				<view class="u-m-l-10 font_14_666">
					匿名评价
				</view>
			</view>
		</view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="submit">发表评价</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: 5,
				content:'',
				chboxSel:false,
				order_id:'',
				type:''
			}
		},
		onLoad(e) {
			this.type = e.type
			this.order_id = e.id
		},
		methods: {
			submit(){
				this.$api({
					url: '/user/comment_by_oid',
					method: 'post',
					data: {
						token:uni.getStorageSync("token"),
						order_id:this.order_id,
						level:this.value,
						show:this.chboxSel?'1':'0',
						content:this.content,
						type:this.type
					},
				}).then(res => {
					if (res.code == 1) {
						
						uni.showToast({
							title: "评论成功",
							icon: "none"
						});
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					} 
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.input-div{
		width: 686rpx;
		padding: 24rpx;
		background: #FFFFFF;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		
		.input-lable{
			font-size: 28rpx;
			color: #000000;
			padding-right: 24rpx;
		}
		
		.input-value{
			width: 500rpx;
		}
	}

	.chbox {
		width: 32rpx;
		height: 32rpx;
		background: #F81B1B;
		border-radius: 50%;
		text-align: center;
		// line-height: 24rpx;
	}
	
	.chbox-no {
		width: 32rpx;
		height: 32rpx;
		border-radius: 50%;
		border: 1px #999 solid;
	}

	
	.btn-bo{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0,0,0,0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		
		.btn_login_btn{
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #FFFFFF;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
		}
	}
</style>
